//
//  ActivityTableViewCell.m
//  ICrEAM
//
//  Created by kuroro on 16/11/2.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ActivityTableViewCell.h"

@implementation ActivityTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)SetUpHeaderViewWithTitle:(NSDictionary *)dic{
    __weak typeof(self) weakSelf = self;
    if (self.activityLabel) {
        [self.activityLabel removeFromSuperview];
    }
    self.backgroundColor = BackgroundColor_White;
    NSString *nameStr = @"";
    if(!dic[@"TECH_ACTI_NAME"] || dic[@"TECH_ACTI_NAME"] == [NSNull null])
    {
        nameStr = @"";
    }
    else
    {
        nameStr = dic[@"TECH_ACTI_NAME"];
    }
    UILabel *activityLabel = [self createLabelWithText:nameStr textAlignment:NSTextAlignmentLeft];
    if ([dic[@"IS_TECH_ACT"] integerValue]==12781002) {
        activityLabel.textColor=RGB(255, 0, 0);
    }
    self.activityLabel = activityLabel;
    [self.contentView addSubview:activityLabel];
    [activityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView.mas_top).offset(ActualHeight(4));
        make.left.equalTo(weakSelf.contentView.mas_left);
        make.right.equalTo(weakSelf.contentView.mas_right);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(ActualHeight(-4));
    }];
    
    
}

- (void)SetUpHeaderViewWithString:(NSString *)string{
    __weak typeof(self) weakSelf = self;
    if (self.activityLabel) {
        [self.activityLabel removeFromSuperview];
    }
    self.backgroundColor = BackgroundColor_White;
    UILabel *activityLabel = [self createLabelWithText:string?:@"" textAlignment:NSTextAlignmentLeft];
    self.activityLabel = activityLabel;
    [self.contentView addSubview:activityLabel];
    [activityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView.mas_top).offset(ActualHeight(4));
        make.left.equalTo(weakSelf.contentView.mas_left);
        make.right.equalTo(weakSelf.contentView.mas_right);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(ActualHeight(-4));
    }];
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (UILabel *)createLabelWithText:(NSString *)text  textAlignment:(NSTextAlignment)textAlignment{
    UILabel *label = [[UILabel alloc] init];
    label.backgroundColor = BackgroundColor_Gray;
    label.layer.borderWidth = 1;
    label.layer.borderColor = SepColor_gray.CGColor;
    label.text = text;
    label.font = TitleFont;
    label.textColor = ContentTextColor_Black;
    label.textAlignment = textAlignment;
    return label;
}

@end
